{extend name="wap@style/base" /}
{block name="resources"}
<style>
    .red-star{
    color: red;
}
</style>

{/block}

{block name="main"}
<div class="hui-wrap">

    <div>
        <div class="hui-tab">
            <div class="hui-tab-title">
                <div>选择分类</div>
                <div>填写内容</div>
            </div>
            <div class="hui-tab-body">
                <div class="hui-tab-body-items">
                    <div class="hui-tab-item">
                        <div class="section">
                            {foreach $category_list as $key=>$vo }
                            <div class="project">
                                <div class="hui-title">
                                    {$vo.name}
                                </div>
                                <div class="items hui-tags">
                                    {foreach $vo['child_list'] as $key => $val}
                                    <div class="category">
                                        <a href="javascript:;" category='{$val.category_id}'>{$val.name}</a>
                                    </div>
                                    {/foreach}
                                </div>
                            </div>
                            <div class="grey-bar"></div>
                            {/foreach}
                        </div>
                    </div>
                    <div class="hui-tab-item info-attribute">

                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

{/block}
{block name="bottom"}
{/block}
{block name="script"}
<script src="__STATIC__/ext/hui/js//hui-tab.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/ext/hui/js/hui-form.js"></script>
<script type="text/javascript">
    // 获取info_id
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }
    var info_id = GetQueryString('info_id');
    var category_id, category_name;
    hui.tab('.hui-tab'); //参数为一个选择器用来选择选项卡外层
    hui.ready(function () {
        hui('.category a').click(function () {

            category_id = hui(this).attr('category');
            category_name = $(this).parents('.project').find('.hui-title').text() + '/' + $(this).text();
            category_name = category_name.replace(/\s/g,"");
            hui.ajax({
                type: "POST",
                url: nc.url("sns://wap/member/infoAttribute"),
                data: {
                    category_id,
                    category_name
                },
                dataType: "JSON",
                success: function (res) {
                    hui('.hui-tab-title div').eq(1).trigger('click');
                    $('.info-attribute').html(res);
                    hui('#category_id').val(category_id);
                    $("#category_name").val(category_name)
                }
            });
        })

    })
    // 编辑信息时直接显示form
    if (info_id) {
        hui.ajax({
            type: "POST",
            url: nc.url("sns://wap/member/editInfoAttribute"),
            data: {
                info_id
            },
            dataType: "JSON",
            success: function (res) {
                hui('.hui-tab-title div').eq(1).trigger('click');
                $('.info-attribute').html(res);
            }
        });
    }




    //获取复选框的值
    function showCheckRes(_selfBtn) {
        var vals = new Array();
        hui(_selfBtn).parent().find('input').each(function (cObj) {
            if (cObj.checked) {
                vals.push(cObj.value);
            }
        });
        // console.log(vals);
    }

    //一句话即可完成js工作数字加减
    hui.numberBox();

    //获取单选框的值
    function showSelectRes(_selfBtn) {
        var val;
        hui(_selfBtn).parent().find('input').each(function (cObj) {
            if (cObj.checked) {
                val = cObj.value;
            }
        });
        console.log(val);
    }

    //图片上传
    function file_upload(obj) {
        var id = $(obj).attr("id");
        nc.upload_api(id, 'File.File.imageUpload', {}, function (res) {
            $('#uploaderFiles').append('<li class="nc-uploader__file" style="background-image:url(' + nc.img(res
                .data.path) + ')" path = "' + res.data.path + '"></li>')
        }, false);
    }
</script>
{/block}